package com.yhj.blog.framework.object;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.Id;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import java.io.Serializable;
import java.util.Date;

/**
 * @author 杨华京
 * @version 1.0
 * @description
 * @since 1.8
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class BaseConditionVO {

    private final static int DEFAULT_PAGE_SIZE=10;
    private int pageNumber=1;
    private int pageSize=0;
    private int pageStart=0;
    private String orderField;
    private String keywords;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startData;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endData;
    public int getPageSize(){
        return pageSize>0?pageSize:DEFAULT_PAGE_SIZE;
    }
    public int getPageStart(){
        return pageNumber>0?(pageNumber-1)*getPageSize():0;
    }
}
